<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
    <!-- 生产环境中不建议使用 jsx babel转译库 将jsx转化为原生js -->
    <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
</head>
<body>
    <div id="example"></div>
        <script type="text/babel">
            // function Mailbox(props){
            //     const unreadMessages=props.unreadMessages;
            //     return (
            //         <div>
            //             <h1>Hello!</h1>
            //             {
            //                 unreadMessages.length>0&&
            //                 <h2>您有{unreadMessages.length}条未读信息</h2>
            //             }
            //         </div>
            //     )
            // }


            //三元运算 
            function Mailbox(props){
                const unreadMessages=props.unreadMessages;
                return (
                    <div>
                        <h1>Hello!</h1>
                        {
                            unreadMessages.length>0?
                            <h2>您有{unreadMessages.length}条未读信息</h2>
                            :
                            <h2>您没有未读信息</h2>
                        }
                    </div>
                )
            }
            // const messages=['React','Re:React','Re:Re:React'];
            const messages=[];
            ReactDOM.render(
                <Mailbox unreadMessages={messages}/>,
                document.getElementById('example')
            )
        </script>
</body>
</html>